﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oracle.DataAccess.Client;

namespace TP2
{
    class LogicClass
    {           
        public LogicClass()
        {
            
        }

        public string GetFinishDate(DateTime startDate, int Period)
        {
            
            string finish_date;
            int period;
            period = Period;//Convert.ToInt32(dataGridView1[2, index].Value);
            int year = startDate.Year + period / 12;
            int month = startDate.Month + period % 12;
            if (month > 12) { year++; month = month - 12; }
            finish_date = "'" + startDate.Day.ToString() + "," + month + "," + year + "'";
            return finish_date;
        }

        public int GetCreditSumm(int summ, Double procent)
        {
            summ = Convert.ToInt32(summ+(summ*procent)/100); 
            return summ;
        }

        public int GetPaymentMonth(int summ, int period)
        {
            int paiment;
            paiment = Convert.ToInt32(summ / period);
            return paiment;
        }

        public bool ClientTest(int Payment, int Income)
        {
            int paymen=Payment;
            int income=Income;
            if (paymen <= income) { return true; } else { return false; }
        }

        public int UpdateDeposit(int Deposit,int Period,Double Procent)
        {
            int deposit=Deposit;
            double procent = Procent;
            DateTime date = System.DateTime.Now;
            int period = Period;
            double procent_bonus=1;
            for (int i = 0; i < period; i++)
            {
              procent_bonus = (1 + (procent / 100))*procent_bonus;
            }
            deposit =Convert.ToInt32(deposit * procent_bonus);         
            return deposit;
        }

    }
}
